﻿
using System;

namespace Test30.Engine
{
    public class Attack
    {
        public Roller Damage { get; }
        public string Verb { get; }
        public EffectType EffectType { get; }
        public IFlagCollection Flags { get; }
        public int StrikeBonus { get; set; }
        public float DamageBonus { get; set; }
        public Element Element { get; set; }
        public float Average => (int) Math.Round(Damage.Average * DamageBonus);
        public Attack(Roller damage, int strikeBonus, float damageBonus,
            Element element, string verb, EffectType effectType,
            IFlagCollection flags)
        {
            Damage = damage;
            StrikeBonus = strikeBonus;
            DamageBonus = damageBonus;
            Element = element;

            Verb = verb;
            EffectType = effectType;
            Flags = flags;
        }
        public Attack(Roller damage, Element element, string verb, EffectType effectType)
            : this(damage, 0, 1.0f, element, verb, effectType, new FlagCollection())
        {
        }

        public Attack(Roller damage, string verb, EffectType effectType)
            : this(damage, 0, 1.0f, Element.Anima, verb, effectType, new FlagCollection())
        {
        }

        public Attack(Roller damage, string verb)
            : this(damage, 0, 1.0f, Element.Anima, verb, EffectType.Hit, new FlagCollection())
        {
        }

        public Attack(Attack attack, Element element)
            : this(attack.Damage, attack.StrikeBonus, attack.DamageBonus,
                   element, attack.Verb, attack.EffectType, attack.Flags)
        {
        }
        public Attack(Roller damage, Element element, string verb)
            : this(damage, 0, 1.0f, Element.Anima, verb, EffectType.Hit, new FlagCollection())
        {
        }
        public int Roll()
        {
            return (int)Math.Round(Damage.Roll() * DamageBonus);
        }

    }
}
